@extends('layouts.admin')
@section('resources')
    <script src="{{asset('public/resources/uploadify/jquery.uploadify.min.js')}}" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="{{asset('public/resources/uploadify/uploadify.css')}}">
    @endsection
@section('content')
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="{{url('Admin/info')}}">首页</a> &raquo; <a href="{{url('Admin/slider')}}">轮播管理</a> &raquo; 添加轮播图
    </div>
    <!--面包屑导航 结束-->

	<!--结果集标题与导航组件 开始-->
	<div class="result_wrap">
        <div class="result_title">
            <h3>快捷操作</h3>
            @if(count($errors)>0)
            <div class="mark">
                @foreach($errors as $err)
                <p>{{$err}}</p>
                @endforeach
            </div>
            @endif
        </div>
        <div class="result_content">
            <div class="short_wrap">
                <a href="{{url('Admin/slider')}}"><i class="fa fa-adjust"></i>slider 列表</a>
            </div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->

    <div class="result_wrap">
        <form action="{{url('Admin/slider')}}" method="post" >
            {{csrf_field()}}
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th><i class="require">*</i> slider 描述 </th>
                        <td>
                            <input type="text" name="s_title" class="lg">
                        </td>
                    </tr>
                    <tr>
                        <th> 导航链接地址 </th>
                        <td>
                            <input type="text" name="link_url">
                        </td>
                    </tr>
                    <tr>
                        <th> <i class="require">*</i> 上传图片</th>
                        <td>
                            <input id="file_upload" name="art_image" type="file" multiple="true">
                            <input type="hidden" name="img_src" value="" id="image_src">
                            <div
                                    class="afterUpload"
                            >
                                <img src="" alt="" style="height: 120px;" id="uploadedimage">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input type="submit" value="提交">
                            <input type="button" class="back" onclick="history.go(-1)" value="返回">
                        </td>
                    </tr>
                </tbody>
            </table>

        </form>

    </div>
    <script type="text/javascript">
        <?php $timestamp = time();?>
        $(function() {
            $('#file_upload').uploadify({
                'buttonText':'上传图片',
                'formData'     : {
                    'timestamp' : '<?php echo $timestamp;?>',
                    'token'     : '{{csrf_token()}}'
                },
                'swf'      : '{{asset("public/resources/uploadify/uploadify.swf")}}',
                'uploader' : '{{url('/imageUpload?rootPath=slider')}}',
                'onUploadSuccess':function (file,data,responce) {
                    if(responce==true){
                        var location = window.location.host;
                        $("#uploadedimage").attr('src','/'+data);
                        $("#image_src").val(data);
                    }else{
                        alert("上传失败！");
                    }
                }

            });
        });
    </script>
    <style>
        .uploadify{display:inline-block;}
        .uploadify-button{border:none; border-radius:5px; margin-top:8px;background: #3a87ad}
        table.add_tab tr td span.uploadify-button-text{color: #FFF; margin:0;}
    </style>
@endsection
